package com.cloudlinkscm.loms.services.base.notify.client;

import com.cloudlinkscm.loms.framework.cloud.feign.GenericFeignClientConfiguration;
import com.cloudlinkscm.loms.framework.core.pojo.RestfulApiResponse;
import com.cloudlinkscm.loms.services.base.notify.constant.NotifyCenterMicroService;
import com.cloudlinkscm.loms.services.base.notify.dto.email.EmailMessageDto;
import com.cloudlinkscm.loms.services.base.notify.dto.SendResultDto;
import com.cloudlinkscm.loms.services.base.notify.service.EmailRemoteService;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author : tac
 * @date : 2017/6/15
 */


@FeignClient(name = NotifyCenterMicroService.SERVICE_NAME, path = EmailRemoteService.PATH, fallback = EmailClient.HystrixFallbackService.class, configuration = GenericFeignClientConfiguration.class)
public interface EmailClient extends EmailRemoteService {

    @Component
    class HystrixFallbackService implements EmailClient{

        @Override
        public RestfulApiResponse<SendResultDto> sendEmail(@RequestBody EmailMessageDto emailMessageDto) {
            return RestfulApiResponse.failure("","fallback");
        }
    }

}
